<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>剩余参数和展开运算符</title>
</head>
<body>
   <script>
    show = (num1, num2, ...num3) => console.log("num1:" + num1 + "," +"num2:" + num2 + "," + "num3:" + num3)
    // function show(num1,num2,...num3){
    // return console.log("num1:" + num1 + "," +"num2:" + num2 + "," + "num3:" + num3)
    // }
    show(1,2,3,4,5,6)

    let arrs = [12,5,8];

    function showNums(a,b,c) { 
        alert(a+b+c)
     }
    showNums(...arrs)
    //不用展开运算符的话会把值都给a,用的话会给a和b和c

    //数组连接
    let arr1 = [1,2,3];
    let arr2 = [4,5,6];
    let arr = [...arr1, ...arr2];
    console.log("arr内容为:" + arr)

    let json = {
        a:1,
        b:2,
        c:3
    }
    let json2 = {
        //第一个参数为"json"对象的值,通常和合并数组一样
        ...json,
        d:5
    }
    console.log(json2)
   </script> 
<!-- 
    剩余参数:
      收集参数
      展开参数
 -->
</body>
</html>